//
//  IntegralMallDetailsViewController.m
//  lmq
//
//  Created by 马田成 on 2017/4/2.
//  Copyright © 2017年 yuanxin. All rights reserved.
//

#import "IntegralMallDetailsViewController.h"
#import "IntegralMallDetailsTableViewCell.h"
#import "Masonry.h"
#import "WXApi.h"
#import "configddd.h"
#import "ActivitiesPublishViewController.h"
#import "AllParticipateRecordsViewController.h"
#import "SDCycleScrollView.h"
#import "UIImageView+WebCache.h"
#import "IntegralMallDetailsModel.h"

#import "IntegralMallParticipateView.h"
#import "IntegralMallClearingVC.h"
#import <MJRefresh/MJRefresh.h>
#import "addressViewController.h"

@interface IntegralMallDetailsViewController ()<UITableViewDelegate, UITableViewDataSource,SDCycleScrollViewDelegate>

{
    UIView *grayView;
    
}

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableDictionary *dataArr;
@property (nonatomic, strong) UIButton *rightButton;
@property(nonatomic,strong)UIView *shadow;
@property (nonatomic,strong) SDCycleScrollView *cycleScrollView;
@property (nonatomic, strong)IntegralMallParticipateView *nowView;

@property (nonatomic, strong) NSMutableArray *smallPicArr;
@property (nonatomic, strong) NSMutableArray *bigPicArr;
@property (nonatomic, strong) NSMutableArray *arr;
@property (nonatomic, assign) NSInteger data;


@end

@implementation IntegralMallDetailsViewController
- (void)viewWillAppear:(BOOL)animated{
    [self creationDate];
    self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreTopic)];
    [self.tableView.mj_footer endRefreshing];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    [self creationView];
    [self regeditCell];
    
    
    // Do any additional setup after loading the view.
}
- (void)creationView{

    self.navigationItem.title = @"商品详情";
//    self.tableView = [[UITableView alloc] init];
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT-64) style:UITableViewStyleGrouped];
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    UIButton *buttonOfBuy = [[UIButton alloc] init];
    [self.view addSubview:buttonOfBuy];
    buttonOfBuy.backgroundColor = [UIColor blackColor];
    [buttonOfBuy setTitle:@"立即购买" forState:UIControlStateNormal];
    [buttonOfBuy setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    
    [buttonOfBuy addTarget:self action:@selector(buyNow) forControlEvents:UIControlEventTouchUpInside];
    [buttonOfBuy mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.offset(40);
        
    }];

    
    
    self.shadow = [[UIView alloc]init];
    
    
    
    self.rightButton=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, screenScale(35), screenScale(35))];
    self.rightButton.selected = NO;
    [self.rightButton addTarget:self action:@selector(rightNavItemClick) forControlEvents:UIControlEventTouchUpInside];
    [self.rightButton setBackgroundImage:[UIImage imageNamed:@"share"] forState:UIControlStateNormal];
    [self.rightButton setBackgroundImage:[UIImage imageNamed:@"share"] forState:UIControlStateSelected];
    UIBarButtonItem *rightBarButton=[[UIBarButtonItem alloc]initWithCustomView:self.rightButton];
    self.navigationItem.rightBarButtonItem=rightBarButton;
    
}
- (void)regeditCell{
    
    
    
    [self.tableView registerNib:[UINib nibWithNibName:@"IntegralMallDetailsTableViewCell" bundle:nil] forCellReuseIdentifier:@"IntegralMallDetailsTableViewCell"];
    
}

- (void)setShadow:(UIView *)shadow{
    
    _shadow = shadow;
    _shadow.frame = CGRectMake(0, DEF_SCREEN_HEIGHT, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT);
    _shadow.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
    _shadow.hidden = YES;
    [[[UIApplication sharedApplication]keyWindow]addSubview:_shadow];
    
    //分享背景
    
    UIView *shareView = [[UIView alloc]initWithFrame:CGRectMake(0, screenScale(1136 - 278), DEF_SCREEN_WIDTH, screenScale(280))];
    shareView.backgroundColor = [UIColor whiteColor];
    [_shadow addSubview:shareView];
    
    //微信btn
    
    UIButton *wechatBtn = [[UIButton alloc]initWithFrame:CGRectMake(screenScale(180), screenScale(62), screenScale(84), screenScale(100))];
    [wechatBtn addTarget:self action:@selector(wechatBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [shareView addSubview:wechatBtn];
    
    UIImageView *wechatImg = [[UIImageView alloc]initWithFrame:CGRectMake(screenScale(8), 0, screenScale(68), screenScale(68))];
    wechatImg.image = [UIImage imageNamed:@"wechat"];
    [wechatBtn addSubview:wechatImg];
    
    UILabel *wechatLable = [[UILabel alloc]initWithFrame:CGRectMake(0, screenScale(75), screenScale(84), screenScale(30))];
    wechatLable.text = @"微信";
    wechatLable.textAlignment = NSTextAlignmentCenter;
    wechatLable.font = get4sFont(13);
    [wechatBtn addSubview:wechatLable];
    
    //朋友圈btn
    
    UIButton *friendsBtn = [[UIButton alloc]initWithFrame:CGRectMake(screenScale(380), screenScale(62), screenScale(84), screenScale(100))];
    [friendsBtn addTarget:self action:@selector(friendsBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [shareView addSubview:friendsBtn];
    
    UIImageView *friendsImg = [[UIImageView alloc]initWithFrame:CGRectMake(screenScale(8), 0, screenScale(68), screenScale(68))];
    friendsImg.image = [UIImage imageNamed:@"friends"];
    [friendsBtn addSubview:friendsImg];
    
    UILabel *friendLable = [[UILabel alloc]initWithFrame:CGRectMake(0, screenScale(75), screenScale(84), screenScale(30))];
    friendLable.text = @"朋友圈";
    friendLable.textAlignment = NSTextAlignmentCenter;
    friendLable.font = get4sFont(13);
    [friendsBtn addSubview:friendLable];
    
    //取消
    
    UIView *thread = [[UIView alloc]initWithFrame:CGRectMake(screenScale(20), screenScale(193), scrWidth() - screenScale(40), screenScale(1))];
    thread.backgroundColor = getColor(@"dcdcdc");
    [shareView addSubview:thread];
    
    UIButton *cancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, screenScale(194), scrWidth(), screenScale(85))];
    cancelBtn.titleLabel.font = get4sFont(15);
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [cancelBtn addTarget:self action:@selector(cancelBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [shareView addSubview:cancelBtn];
}

- (void)wechatBtnClick{
    
    NSLog(@"微信分享");
    
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = @"乐麦圈";
    message.description = @"";
    [message setThumbImage:[UIImage imageNamed:@""]];
    
    WXWebpageObject *webpageObject = [WXWebpageObject object];
    webpageObject.webpageUrl = @"http://lmq.quyum.cn/home/register/regweb/invitation/a4bi31j1";
    message.mediaObject = webpageObject;
    
    SendMessageToWXReq *req = [[SendMessageToWXReq alloc]init];
    req.bText = NO;
    req.message = message;
    req.scene = WXSceneSession;
    
    [WXApi sendReq:req];
}

- (void)friendsBtnClick{
    
    NSLog(@"朋友圈分享");
    
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = @"乐麦圈";
    message.description = @"";
    [message setThumbImage:[UIImage imageNamed:@""]];
    //@"http://112.74.36.208/"
    WXWebpageObject *webpageObject = [WXWebpageObject object];
    webpageObject.webpageUrl = @"http://lmq.quyum.cn/home/register/regweb/invitation/a4bi31j1";
    message.mediaObject = webpageObject;
    
    SendMessageToWXReq *req = [[SendMessageToWXReq alloc]init];
    req.bText = NO;
    req.message = message;
    req.scene = WXSceneTimeline;
    
    [WXApi sendReq:req];
}

- (void)cancelBtnClick{
    
    NSLog(@"取消");
    
    [UIView beginAnimations:@"ResizeForKeyBoard" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    _shadow.frame = CGRectMake(0, DEF_SCREEN_HEIGHT, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT);
    [UIView commitAnimations];
    _shadow.hidden = YES;
}

- (void)creationDate{
    
    _dataArr = [[NSMutableDictionary alloc]init];
    _arr = [[NSMutableArray alloc]init];
    _smallPicArr = [NSMutableArray array];
    _bigPicArr = [NSMutableArray array];
    
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];

    [productParams setValue:_addTime forKey:@"add_time"];
    [productParams setValue:_shopid forKey:@"shop_id"];
    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];
    NSString *memberId = [PublicFunction getConfigWithKey:@"uid"];
    [productParams setValue:tokenStr forKey:@"token"];
    [productParams setValue:memberId forKey:@"member_id"];
    
    
    [[MNetworkHandler sharedInstance]conURL:Home_OneshowShowShop
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       NSDictionary *dict1=[returnData objectForKey:@"data"];
                                       ;
                                       _dataArr = [dict1 objectForKey:@"shop"];
                                       _smallPicArr = [dict1 objectForKey:@"smail"];
                                       _bigPicArr = [dict1 objectForKey:@"big"];
                                       
                                      
                                       
                                       [_arr addObject:_dataArr];

                                       
                                       
                                       [self.tableView reloadData];
                                   }
                                   else {
                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];
    //中间cell数据
    [[MNetworkHandler sharedInstance]conURL:Home_OneShowAttend
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==-3) {
                                       
                                       
                                       _data = [[returnData objectForKey:@"data"] integerValue];
                                       
                                       [self.tableView reloadData];
                                   }
                                   else {
                                       _data = 0;
                                       
                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];
    

    
    
    
    
}


#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
//自定义section的头部
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *lunBoView = [[UIView alloc] init];
    
    lunBoView.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, 200);
//    NSArray *arrMu = @[@"liyi",@"liyi",@"liyi"];
    self.cycleScrollView=[SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, -35, DEF_SCREEN_WIDTH, 200) imageNamesGroup:self.smallPicArr];
    self.cycleScrollView.backgroundColor=[UIColor greenColor];
    self.cycleScrollView.pageControlAliment=SDCycleScrollViewPageContolAlimentCenter;
    self.cycleScrollView.delegate = self;
    self.cycleScrollView.pageDotColor = [UIColor grayColor]; // 自定义分页控件小圆标颜色
    
    NSMutableArray *myarr=[[NSMutableArray alloc]init];
    for (int i=0; i<self.smallPicArr.count; i++) {
        
        NSString *str=[self.smallPicArr[i] objectForKey:@"pic"];
        NSString *urlN=manage(AP_HOST, str);
        NSString *strUrl = [urlN stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
        [myarr addObject:strUrl];
    }
    [self.cycleScrollView setLocalizationImageNamesGroup:myarr];
    [self.cycleScrollView reloadInputViews];
    self.cycleScrollView.currentPageDotImage=[UIImage imageNamed:@"hei"];
    self.cycleScrollView.pageDotImage=[UIImage imageNamed:@"hui"];
    self.cycleScrollView.placeholderImage = [UIImage imageNamed:@""];
    [lunBoView addSubview:self.cycleScrollView];
    
    return lunBoView;
}

#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", index);
    
}
#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    
    
    
    
    return 200;
    
    
}
//section 不随tableView滑动
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    if (scrollView == self.tableView)
        
    {
        
        CGFloat sectionHeaderHeight = 200; //header高度
        
        if (scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0) {
            
            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
            
        } else if (scrollView.contentOffset.y >= sectionHeaderHeight) {
            
            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
            
        }
        
    }
    
    
    
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _arr.count;
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 250;
    
}
#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    IntegralMallDetailsTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"IntegralMallDetailsTableViewCell" forIndexPath:indexPath];
    
    cell.nameLabel.text = [self.dataArr objectForKey:@"name"];
    NSString *str1 = @"总需";
    NSString *str2 = @"人次";

    cell.purchaseLabel.text = [[str1 stringByAppendingString:[self.dataArr objectForKey:@"purchase"]] stringByAppendingString:str2];
    
    
    NSString *str3 = @"(";
    NSString *str4 = @"积分/人次)";
    
    
    cell.priceLabel.text = [[str3 stringByAppendingString:[self.dataArr objectForKey:@"price"]] stringByAppendingString:str4];
    float num1 = [[self.dataArr objectForKey:@"purchase"] floatValue];
    float num2 = [[self.dataArr objectForKey:@"buy"] floatValue];
    
//    [dict3 objectForKey:@"buy"];
    
    cell.numberLabel.text = [NSString stringWithFormat:@"%.0f", num1 - num2];
    
    
    cell.progressView.progress = num2 / num1;
    
    
    [cell.activitiesPublish addTarget:self action:@selector(activitiesPublishVC) forControlEvents:UIControlEventTouchUpInside];
    
    [cell.allParticiateRButton addTarget:self action:@selector(allParticiateRClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    if (_data == 0) {
        cell.ninCanJLabel.text = @"您没有参加本次夺宝";
    }else {
    
    NSString *dataO = @"您参加了本期";
    NSString *numOfData = [NSString stringWithFormat:@"%ld", (long)_data];
    
    cell.ninCanJLabel.text = [[dataO stringByAppendingString:numOfData] stringByAppendingString:@"次夺宝"];
    
    }
    
    
    
    return cell;
    
    
}
//立即购买
- (void)buyNow{
    
    grayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height+64)];
    grayView.backgroundColor = [UIColor blackColor];
    grayView.alpha = 0.4;
    grayView.tag = 111;
    //    [[UIApplication sharedApplication].keyWindow addSubview:grayView];
    [self.view addSubview:grayView];
    
    _nowView = [[NSBundle mainBundle] loadNibNamed:@"IntegralMallParticipateView" owner:self options:nil].lastObject;
    [self.view addSubview:self.nowView];
    [self.nowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.offset(310);
        
    }];
    self.nowView.backgroundColor = [UIColor whiteColor];
    

    [self.nowView.canceButton addTarget:self action:@selector(canceClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.nowView.nowPurchaseButton addTarget:self action:@selector(nowingPurchaseClick) forControlEvents:UIControlEventTouchUpInside];
    self.nowView.price = _dataArr[@"price"];
    
    float num1 = [[self.dataArr objectForKey:@"purchase"] floatValue];
    float num2 = [[self.dataArr objectForKey:@"buy"] floatValue];
    self.nowView.numberLabel = [NSString stringWithFormat:@"%.0f", num1 - num2];

    
    
    // 单击的 Recognizer
    UITapGestureRecognizer* singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(SingleTap:)];
    
    
    [grayView addGestureRecognizer:singleRecognizer];

    

}
#pragma mark - 点击右导航
-(void)rightNavItemClick{
    
    NSLog(@"分享");
    
    [UIView beginAnimations:@"ResizeForKeyBoard" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    _shadow.hidden = NO;
    _shadow.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT);
    [UIView commitAnimations];
}
//往期揭晓
- (void)activitiesPublishVC{

    ActivitiesPublishViewController *vc = [[ActivitiesPublishViewController alloc] init];
    vc.shop_id =[self.dataArr objectForKey:@"shop_id"];
    [self.navigationController pushViewController:vc animated:YES];
    

}
//_dataArr所有参与记录
- (void)allParticiateRClick{

    AllParticipateRecordsViewController *vc = [[AllParticipateRecordsViewController alloc] init];
    
    vc.shop_id = [self.dataArr objectForKey:@"shop_id"];
    vc.stage = [self.dataArr objectForKey:@"add_time"];
    
    
    [self.navigationController pushViewController:vc animated:YES];
    
    
    
}
//立即购买view
- (void)nowingPurchaseClick{
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    [productParams setValue:[self.dataArr objectForKey:@"shop_id"] forKey:@"shop_id"];
    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];
    NSString *memberId = [PublicFunction getConfigWithKey:@"uid"];
    [productParams setValue:tokenStr forKey:@"token"];
    [productParams setValue:memberId forKey:@"member_id"];
    if ([self.nowView.numberTextField.text intValue] >= [self.nowView.numberLabel intValue]) {
        [productParams setValue:self.nowView.numberLabel forKey:@"num"];
    
    }else {
    [productParams setValue:self.nowView.numberTextField.text forKey:@"num"];
        
    }
    [[MNetworkHandler sharedInstance]conURL:Home_OnebuyToAccount
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       IntegralMallClearingVC *vc = [[IntegralMallClearingVC alloc] init];
                                       if ([self.nowView.numberTextField.text intValue] >= [self.nowView.numberLabel intValue]) {
                                           vc.num = self.nowView.numberLabel;
                                           
                                       }else {
                                           vc.num = self.nowView.numberTextField.text;
                                           
                                       }
                                       
                                       
                                       vc.shop_id = [self.dataArr objectForKey:@"shop_id"];
                                       [self.navigationController pushViewController:vc animated:YES];
                                       
                                       
                                       NSLog(@"%@", returnData);
                                       
                                   }
                                   else if ([[returnData objectForKey:@"code"]intValue]==-3){
                                       
                                       addressViewController *vc = [[addressViewController alloc] init];
                                       
                                       [self.navigationController pushViewController:vc animated:YES];
   
                                       
                                   } else {
                                   [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                       
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];

    
    
    

}
//点击隐藏view
-(void)SingleTap:(UITapGestureRecognizer*)recognizer  {
    
    
    self.nowView.hidden = YES;
    grayView.hidden = YES;
    
 
}
- (void)canceClick{

    self.nowView.hidden = YES;
    grayView.hidden = YES;

}
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, scrWidth(), screenScale(66))];
    footerView.backgroundColor = getColor(@"f5f5f5");
    
    //刷新之后
    footerView2 = [[UIView alloc]initWithFrame:CGRectMake(0, screenScale(10), scrWidth(), footViewHeight)];
    footerView2.hidden = !hidden;
    [footerView addSubview:footerView2];
    
    for (int i = 0; i < _bigPicArr.count; i ++) {
        
        int height = 0;
        
        for (int j = 0 ; j < i ; j ++) {
            
            height += [picArr[j] intValue];
        }
        
        UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(0,height, scrWidth(), [picArr[i] intValue])];
        [footerView2 addSubview:img];
        
        NSString *urlWare = [self.bigPicArr[i] objectForKey:@"pic"];
        NSString *urlN = manage(AP_HOST, urlWare);
        
        NSString *strUrl = [urlN stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
        NSURL *urlW = [NSURL URLWithString:strUrl];
        [img sd_setImageWithURL:urlW placeholderImage:[UIImage imageNamed:@"niunai"]];
    }
    
    //上拉刷新文字提示
    footerView1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, scrWidth(), screenScale(66))];
    footerView1.backgroundColor = getColor(@"f5f5f5");
    footerView1.hidden = hidden;
    [footerView addSubview:footerView1];
    
    UIView *threadView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, scrWidth(), screenScale(1))];
    threadView.backgroundColor = getColor(@"dfdfdf");
    [footerView1 addSubview:threadView];
    
    UILabel *footLable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, scrWidth(), screenScale(66))];
    footLable.text = @"继续拖动，查看图文详情";
    footLable.font = get4sFont(11);
    footLable.textAlignment = NSTextAlignmentCenter;
    [footerView1 addSubview:footLable];
    
    return footerView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return footViewHeight + screenScale(10);
}
- (void)loadMoreTopic{
    
    [self.tableView.mj_footer endRefreshing];
    
    picArr = [[NSMutableArray alloc]init];
    footViewHeight = 0;
    
    for (int i = 0 ; i < _bigPicArr.count; i ++) {
        
        NSString *urlGood = _bigPicArr[i][@"pic"];
        NSString *urlN = manage(AP_HOST, urlGood);
        NSString *strUrl = [urlN stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
        
        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:strUrl]];
        UIImage *image = [UIImage imageWithData:data];
        size = image.size;
        
        footViewHeight += size.height/(size.width/scrWidth());
        [picArr insertObject:[NSString stringWithFormat:@"%f",size.height/(size.width/scrWidth())] atIndex:i];
    }
    
    if (_bigPicArr.count > 0) {
        
        hidden = YES;
    }
    NSLog(@"%@",picArr);
    [self.tableView reloadData];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
